﻿using System.Security.Permissions;

namespace ETask.Api.Data
{
    public class UserContext
    {
        private static readonly AsyncLocal<LoginUser> _userInfo = new AsyncLocal<LoginUser>();

        public static LoginUser CurrentUser
        {
            get => _userInfo.Value;
            set => _userInfo.Value = value;
        }

        // 清理当前上下文的用户信息
        public static void Clear()
        {
            _userInfo.Value = null;
        }
    }

    public class LoginUser
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public string Role { get; set; }

        public string Account { get; set; }

        public string Email { get; set; }

        public string Phone {  get; set; }

        public string DeptName { get; set; }

        public DateTime CreatedAt { get; set; }

        public DateTime UpdatedAt { get; set; }
    }
}
